package com.qfmy.app.controller.community;

import com.qfmy.app.service.community.BlogClassService;
import com.qfmy.common.result.Result;
import com.qfmy.model.entity.community.BlogClass;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.app.controller.community
 * @date 2025/4/17
 * @description 博客分类
 */
@RestController
@SuppressWarnings("all")
@RequestMapping("/app/blogClass")
public class BlogClassController {

    /**
     * 博客分类
     */
    @Resource
    private BlogClassService blogClassService;

    /**
     * 获取热们的分类
     */
    @RequestMapping("/getHotClass")
    public Result<List<BlogClass>> getHotClass() {
        List<BlogClass> blogClassList = blogClassService.getHotClass();
        return Result.ok(blogClassList);
    }

    /**
     * 获取所有分类
     */
    @RequestMapping("/getAllClass")
    public Result getAllClass() {
        List<String> blogClassList = blogClassService.getAllClass();
        return Result.ok(blogClassList);
    }

    /**
     * 根据类别获取分类下面的具体的名称
     */
    @RequestMapping("/getByClass")
    public Result getByClass(@RequestParam String className) {
        List<BlogClass> contents = blogClassService.getByClass(className);
        return Result.ok(contents);
    }

    /**
     * 更新类别的浏览次数
     */
    @RequestMapping("/updateClass")
    public Result updateClass(@RequestParam String className) {
        blogClassService.updateClass(className);
        return Result.ok();
    }

}
